package com.wenda.homeschooedu.daoimpl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.wenda.homeschooedu.DB.JDBCConnection;
import com.wenda.homeschooedu.DB.DB.Table;
import com.wenda.homeschooedu.dao.IUserLogin;

public class UserLoginService implements IUserLogin {
	JDBCConnection connection;
	Statement statement;

	public UserLoginService() {
		connection = new JDBCConnection();
		statement = connection.getStm();
	}

	public boolean Login(String username, String password) {
		String sql = String.format(Table.Parent.SQL.SELECT_LOGIN, username,
				password);
		try {
			ResultSet resultSet = statement.executeQuery(sql);
			resultSet.next();
			try {
				resultSet.getString(resultSet.findColumn("name"));
				return true;
			} catch (Exception e) {
				return false;
			}

		} catch (SQLException e) {

			e.printStackTrace();
			return false;
		}

	}

}
